package org.cycuchy.hp.components.book.places {
	
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	
	import mx.controls.Text;
	import mx.events.FlexEvent;
	
	import org.cycuchy.hp.components.book.NumeredPage;

	public class PlacesPageControl_code extends NumeredPage	{
		
		[Bindable]
		public var placesPage:PlacesPage;
		
		private var items:Array = null;
		
//		public var box:VBox;
		public var txt:Text;
				
		public function PlacesPageControl_code() {
			super();
			addEventListener(FlexEvent.CREATION_COMPLETE, creationComplete);
			addEventListener(TextEvent.LINK, link);
			items = [
				{text: "cały", x: -1, y: -1, width: -1, height: -1},			
				{text: "tekst 1", x: 0, y: 0, width: 240, height: 155},
				{text: "tekst 2", x: 292, y: 240, width: 105, height: 77},
				
				{text: "tekst 3", x: 240, y: 20, width: 260, height: 130},
				
				{text: "tekst 4", x: 480, y: 20, width: 125, height: 60},
				
				{text: "tekst 5", x: 600, y: 20, width: 90, height: 175},
				
				{text: "tekst 6", x: 690, y: 20, width: 20, height: 240},
				
				{text: "tekst 6", x: 710, y: 20, width: 20, height: 240},
				
				{text: "tekst 6", x: 733, y: 20, width: 20, height: 240},
				
				{text: "tekst 6", x: 750, y: 10, width: 140, height: 242},
				
				{text: "tekst 6", x: 0, y: 156, width: 182, height: 265},
					
				{text: "tekst 6", x: 183, y: 155, width: 126, height: 268},
				
				{text: "tekst 6", x: 304, y: 147, width: 199, height: 86},
				
				{text: "tekst 6", x: 500, y: 79, width: 102, height: 141},
				
				{text: "tekst 6", x: 394, y: 226, width: 183, height: 90},
				
				{text: "tekst 6", x: 572, y: 212, width: 71, height: 107},
				
				{text: "tekst 6", x: 305, y: 315, width: 210, height: 106},
				
				{text: "tekst 6", x: 513, y: 320, width: 137, height: 90},
				
				{text: "tekst 6", x: 643, y: 260, width: 121, height: 150},
				
				{text: "tekst 6", x: 771, y: 259, width: 134, height: 198},
				
				{text: "tekst 6", x: 0, y: 425, width: 189, height: 130},
				
				{text: "tekst 6", x: 190, y: 423, width: 173, height: 123},
				
				{text: "tekst 6", x: 529, y: 523, width: 206, height: 138},
				
				{text: "tekst 6", x: 730, y: 521, width: 56, height: 140},
				
				{text: "tekst 6", x: 789, y: 458, width: 98, height: 201},
				
				{text: "tekst 6", x: 364, y: 420, width: 204, height: 111},
				
				{text: "tekst 6", x: 566, y: 407, width: 207, height: 112},
				
				{text: "tekst 6", x: 0, y: 550, width: 263, height: 139},
				{text: "tekst 6", x: , y: , width: , height: },
				{text: "tekst 6", x: , y: , width: , height: },
				{text: "tekst 6", x: , y: , width: , height: },
				
			];
		}
		
		private function creationComplete(event:FlexEvent):void {
			removeEventListener(FlexEvent.CREATION_COMPLETE, creationComplete);
			placesPage.items = items;
		}
		
		override protected function createChildren():void {
			super.createChildren();
			var i:uint = 0;
			var s:String = "<font color='#434343' size='+5'>";
			for each (var item:Object in items) {
				s += "<a href='event:" + i + "'>" + item.text + "</a>&nbsp;&nbsp;";
				
				i++;
			}
			s += "</font>";
			txt.htmlText = s;
		}
		
		private function getHandler(i:uint):Function {
		    return function(e:MouseEvent):void {
		       placesPage.f(i)
		    }
		}
		
		private function link(event:TextEvent):void {
			placesPage.f(parseInt(event.text));
		}
		
	}
	
}